﻿/*!	r_draw_inputlayout_desc.h
	@brief	頂点レイアウト
Copyright (c) 2010 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#ifndef _R_DRAW_INPUTLAYOUT_DESC_H_
#define _R_DRAW_INPUTLAYOUT_DESC_H_

#include "r_draw_string.h"
#include <vector>

namespace r{
	namespace draw{
		class InputLayoutDescAttr
		{
		public:
			InputLayoutDescAttr ( const r_mstr _semanticName, r_ui32 _format, r_ui32 _offset, r_ui32 _semanticIndex = 0, r_ui32 _slotIndex = 0 );
			InputLayoutDescAttr ( const r_wstr _semanticName, r_ui32 _format, r_ui32 _offset, r_ui32 _semanticIndex = 0, r_ui32 _slotIndex = 0 );
			virtual ~InputLayoutDescAttr();
		public:
			const r_mstr		getSemanticNameM() const;
			const r_wstr		getSemanticNameW() const;
			r_ui32				getFormat() const;
			r_ui32				getOffset() const;
			r_ui32				getSemanticIndex() const;
			r_ui32				getSlotIndex() const;
		protected:
		private:
			r::draw::mstring	semanticNameM;
			r::draw::wstring	semanticNameW;
			r_ui32				format;
			r_ui32				offset;
			r_ui32				semanticIndex;
			r_ui32				slotIndex;
		};

		//! 頂点レイアウトを定義する
		class InputLayoutDesc
		{
			typedef std::vector< InputLayoutDescAttr, r::draw::Allocator<InputLayoutDescAttr> >		attr_array;
		public:
			RALLOC_PLACEMENT_NEW_DELETE_DECLEARE
		public:
			InputLayoutDesc();
			virtual ~InputLayoutDesc();
		public:
			//! レイアウトアトリビュートを追加する
			void								add ( const InputLayoutDescAttr& attr );

			//! 登録済みのアトリビュートの数を取得する
			r_size								getAttrNum() const;
			//! アトリビュートを取得する
			const InputLayoutDescAttr*	getAttr ( r_ui32 index ) const;
		protected:
		private:
			attr_array			vertexLayout;
		};
	}
}


#endif // _R_DRAW_INPUTLAYOUT_DESC_H_
